package com.itheima.springbootwebtest.config;

import com.itheima.springbootwebtest.interceptor.WebInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置拦截器
 *
 * @Author mr.luo
 * @Date 14 4月 2025 15:16
 */
@Configuration  // 配置类
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private WebInterceptor webInterceptor;

    //1、重写添加拦截器方法
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //2、添加拦截器
        //3、设置拦截路径 .addPathPatterns("/**")
        //4、排除拦截路径 .excludePathPatterns("/emp/login")
        registry.addInterceptor(webInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/emps/login");
    }
}
